#ifndef UFILECHOOSEREDIT_H
#define UFILECHOOSEREDIT_H

#include "utkwidget_export.h"

#include <QFileDialog>

class ULineEdit;
class UFileChooserEditPrivate;
class UTKWIDGET_EXPORT UFileChooserEdit : public QWidget
{
    Q_OBJECT

    Q_ENUMS(DialogDisplayPosition)

public:
    enum DialogDisplayPosition
    {
        FollowParentWindow,
        CurrentMonitorCenter
    };

    UFileChooserEdit(QWidget* parent = nullptr);
    ~UFileChooserEdit();

    void setFileMode(QFileDialog::FileMode mode);
    QFileDialog::FileMode fileMode() const;

    void setNameFilters(const QStringList &filters);
    QStringList nameFilters() const;

    void setDirectoryUrl(const QUrl &directory);
    QUrl directoryUrl();

    void setDialogDisplayPosition(DialogDisplayPosition dialogDisplayPosition);
    UFileChooserEdit::DialogDisplayPosition dialogDisplayPosition() const;

    void setFileDialog(QFileDialog* fileDialog);
    QFileDialog* fileDialog() const;

    ULineEdit* lineEidt() const;

    void initDialog();

    QString fileName() const;

    void clear();

protected:
    void resizeEvent(QResizeEvent* event) override;

Q_SIGNALS:
    void fileChoosed(const QString &fileName);
    void dialogOpened();
    void dialogClosed(int code);

private:
    QScopedPointer<UFileChooserEditPrivate> d_ptr;
    Q_DISABLE_COPY(UFileChooserEdit)
    Q_DECLARE_PRIVATE(UFileChooserEdit)
    Q_PRIVATE_SLOT(d_func(), void _q_showFileChooserDialog())
};

#endif // UFILECHOOSEREDIT_H
